package cn.ctodb.cms.service.mapper;

import cn.ctodb.cms.domain.*;
import cn.ctodb.cms.service.dto.CmsChannelDTO;

import org.mapstruct.*;
import java.util.List;

/**
 * Mapper for the entity CmsChannel and its DTO CmsChannelDTO.
 */
@Mapper(componentModel = "spring", uses = {})
public interface CmsChannelMapper {

    @Mapping(source = "model.id", target = "modelId")
    @Mapping(source = "parent.id", target = "parentId")
    CmsChannelDTO cmsChannelToCmsChannelDTO(CmsChannel cmsChannel);

    List<CmsChannelDTO> cmsChannelsToCmsChannelDTOs(List<CmsChannel> cmsChannels);

    @Mapping(target = "txts", ignore = true)
    @Mapping(target = "channels", ignore = true)
    @Mapping(source = "modelId", target = "model")
    @Mapping(source = "parentId", target = "parent")
    CmsChannel cmsChannelDTOToCmsChannel(CmsChannelDTO cmsChannelDTO);

    List<CmsChannel> cmsChannelDTOsToCmsChannels(List<CmsChannelDTO> cmsChannelDTOs);

    default CmsModel cmsModelFromId(Long id) {
        if (id == null) {
            return null;
        }
        CmsModel cmsModel = new CmsModel();
        cmsModel.setId(id);
        return cmsModel;
    }

    default CmsChannel cmsChannelFromId(Long id) {
        if (id == null) {
            return null;
        }
        CmsChannel cmsChannel = new CmsChannel();
        cmsChannel.setId(id);
        return cmsChannel;
    }
}
